package org.example.market_spring.service;

import org.example.market_spring.entity.Goods;
import org.example.market_spring.entity.SaleTicket;
import org.example.market_spring.mapper.GoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;

    public List<Goods> queryGoods(Goods goods){
        return goodsMapper.queryGoods(goods);
    }

    public List<Goods> queryByIds(String[] id){
        return goodsMapper.queryByIds(id);
    }

    public void updateGoodsNum(String[] id,int tjnum){
        Map<String, Object> params = new HashMap<>();
        for(int i=0;i<id.length;i++){
            params.put("id",id[i]);
            params.put("tjnum",tjnum);
            goodsMapper.updateGoodsNum(params);
        }
    }

    public List<SaleTicket> queryFAMsg(SaleTicket saleTicket){
        return  goodsMapper.queryFAMsg(saleTicket);
    }
}
